<%@page import="model.Keuangan"%>
<%@page import="model.Penjualan"%>
<%@page import="model.Pengadaan"%>
<%@ include file="header.jsp"%>
<%@page import="database.DBProduksi"%>
<%@page import="model.Produksi"%>






<%@page import="java.util.*" %>
<script>
function printDiv()
{
  var divToPrint=document.getElementById('tabel');
  newWin= window.open("");
  newWin.document.write(divToPrint.outerHTML);
  newWin.document.close();
  newWin.print();
  newWin.close();
}
</script>

<!-- start: Content -->
<div id="content" class="span10">


    <ul class="breadcrumb">
        <li>
            <i class="icon-home"></i>
            <a href="index.html">Home</a> 
            <i class="icon-angle-right"></i>
        </li>
        <li><a href="#">Tables</a></li>
    </ul>

    <div class="row-fluid sortable" id="hehe">		
        <div class="box span12">
            <div class="box-header" data-original-title>
                <h2><i class="halflings-icon user"></i><span class="break"></span>Laporan</h2>

            </div>

            <div class="box-content">
                <form class="form-horizontal" method="post" action="KeuanganServlet" name="pengadaan">
                    <fieldset>


                        <div class="control-group success">
                            <label class="control-label" for="laporan">Laporan :</label>
                            <div class="controls">
                                <select id="laporan" name="laporan" data-rel="chosen">
                                    <option value=""></option>
                                    <option value="1">Produksi</option>
                                    <option value="2">Pengadaan</option>



                                </select>

                            </div>
                        </div>

                        <div class="control-group success">
                            <label class="control-label" for="ttl">Tanggal Awal:</label>
                            <div class="input-group date form_date controls" data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                                <input class="input-xlarge" size="16" type="text" readonly id="tgl1" name="tgl1"  required value="<%=request.getAttribute("tgl1")!= null ? request.getAttribute("tgl1") : ""%>">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                            </div>

                        </div>


                        <div class="control-group success">
                            <label class="control-label" for="ttl">Tanggal Akhir:</label>
                            <div class="input-group date form_date controls" data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                                <input class="input-xlarge" size="16" type="text" readonly id="tgl2" name="tgl2"  required value="<%=request.getAttribute("tgl2")!= null ? request.getAttribute("tgl2") : ""%>">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                            </div>

                        </div>


                        <div class="form-actions">

                            <button type="submit" class="btn btn-primary" name="action">Cari</button>
                            <button class="btn">Batal</button>
                        </div>
                    </fieldset>
                </form>
                <br>
                <table class="table table-striped table-bordered bootstrap-datatable datatable" name="tabel" id="tabel">
                    <%                        if (request.getAttribute("laporan") == null) {

                        } else if (request.getAttribute("laporan").equals("1")) {
                    %>
                    <thead>
                        <tr>
                            <th>Kode Produksi</th>
                            <th>Kode Barang</th>

                            <th>Jumlah Produksi</th>
                            <th>Jumlah Biaya</th>

                            <th>Tanggal Produksi</th>


                        </tr>
                    </thead> 
                    <tbody>
                        <%
                            Produksi bean = new Produksi();

                            List list = (List) request.getAttribute("list");
                            //  request.setAttribute("list", list);

                            if (list != null) {
                                for (int i = 0; i < list.size(); i++) {
                                    bean = (Produksi) list.get(i);

                        %>

                        <tr>
                            <td><%=bean.getProduksiId()%></td>
                            <td class="center"><%=bean.getKodeBarang()%></td>

                            <td class="center"><%=bean.getJumlahPrduksi()%></td>
                            <td class="center"><%=bean.getBiaya()%></td>

                            <td class="center"><%=bean.getTgl()%></td>


                        </tr>


                        <%
                                }
                            }

                        %>
                    </tbody>
                    <%                         } else if (request.getAttribute("laporan").equals("2")) {


                    %>
                    <thead>
                        <tr>
                            <th>Kode Pengadaan</th>
                            <th>Pegawai</th>
                            <th>Supplier</th>
                            <th>Barang</th>
                            <th>Jumlah Barang</th>
                            <th>Tanggal Pengadaan</th>
                            <th>Harga Satuan</th>
                            <th>Total Harga</th>

                        </tr>
                    </thead> 

                    <tbody>
                        <%                            Pengadaan bean = new Pengadaan();

                            List list = (List) request.getAttribute("list");
                            //  request.setAttribute("list", list);

                            if (list != null) {
                                for (int i = 0; i < list.size(); i++) {
                                    bean = (Pengadaan) list.get(i);

                        %>

                        <tr>
                            <td><%=bean.getPengadaanId()%></td>
                            <td class="center"><%=bean.getNamaPegawai()%></td>

                            <td class="center"><%=bean.getNamaSupplyer()%></td>
                            <td class="center"><%=bean.getNamaBarang()%></td>
                            <td class="center"><%=bean.getJumlahBarang()%></td>
                            <td class="center"><%=bean.getTgl()%></td>
                            <td class="center"><%=bean.getHargaSatuan()%></td>
                            <td class="center"><%=bean.getJumlahHarga()%></td>


                        </tr>


                        <%
                                }
                            }

                        %>
                    </tbody>
                    <%                    } else if (request.getAttribute("laporan").equals("3")) {


                    %>
                    <thead>
                        <tr>
                            <th>Kode Penjualan</th>
                            <th>Nama Pegawai</th>

                            <th>Nama Barang</th>
                            <th>Jumlah Barang</th>
                            <th>Jumlah Harga</th>
                            <th>Tanggal Penjualan</th>

                        </tr>
                    </thead> 

                    <tbody>
                        <%                            Penjualan bean = new Penjualan();
                            List list = (List) request.getAttribute("list");
                            //  request.setAttribute("list", list);

                            if (list != null) {
                                for (int i = 0; i < list.size(); i++) {
                                    bean = (Penjualan) list.get(i);

                        %>

                        <tr>
                            <td><%=bean.getPenjualanId()%></td>
                            <td class="center"><%=bean.getUsername()%></td>

                            <td class="center"><%=bean.getKode_barang()%></td>
                            <td class="center"><%=bean.getJumlahBarang()%></td>
                            <td class="center"><%=bean.getJumlahHarga()%></td>
                            <td class="center"><%=bean.getTgl()%></td>


                        </tr>


                        <%
                                }
                            }

                        %>
                    </tbody>
                    <%                        }
                    %>
                </table>  
            </div>
        </div><!--/span-->

    </div><!--/row-->






</div><!--/.fluid-container-->

<!-- end: Content -->
</div><!--/#content.span10-->
</div><!--/fluid-row-->

<%@ include file="footer.jsp"%>

